function json2s(o) {
	var type = typeof(o);
	if(type == 'number') {
		return o;
	}
	if(type == 'string') {
		return '"' + o + '"';
	}
	if(type == 'boolean') {
		return o;
	}
	if(type == 'undefined') {
		return 'null';
	}
	if(type == 'object') {
		if(o == null) {
			return 'null';
		}
		if(o instanceof Array) {
			var tmps = [];
			o.map(function(e){
				tmps.push(json2s(e));
			});
			return '['+ tmps.join(',') +']';
		}
		var tmps=[];
		for(var prop in o) {
			tmps.push(json2s(prop) + ':' + json2s(o[prop]));
		}
		return '{' + tmps.join(',') + '}';
	}
	return 'null';
}
function s2json(s) {
	return eval('(' + s + ')');
}
function xparseInt(s) {
	var result = parseInt(s);
	if(isNaN(result)) {
		result = 0;
	}
	return result;
}
function xparseLong(s) {
	var result = parseLong(s);
	if(isNaN(result)) {
		result = 0;
	}
	return result;
}
function xparseFloat(s) {
	var result = parseFloat(s);
	if(isNaN(result)) {
		result = 0.0;
	}
	return result;
}
function xparseString(s) {
	if(s == null) {
		s="";
	}
	return s;
}
String.prototype.trim = function()
{
	return this;
}
function checkInteger(name,value,nullable) {
	if(value == null){value="";}
	value = value.trim();
	if(nullable) {
		if(value == "") {
			return true;
		}else{
			value = value.trim();
			if(isNaN(parseInt(value))) {
				alert(name + "必须是整数");
				return false;
			}
		}
	}else {
		if(value == "") {
			alert(name + "不可为空");
			return false;
		}else {
			if(isNaN(parseInt(value))) {
				alert(name + "必须是整数");
				return false;
			}
		}
	}
	return true;
}
function checkLong(name,value,nullable) {
	if(value == null){value="";}
	value = value.trim();
	if(nullable) {
		if(value == "") {
			return true;
		}else{
			if(isNaN(parseLong(value))) {
				alert(name + "必须是长整数");
				return false;
			}
		}
	}else {
		if(value == "") {
			alert(name + "不可为空");
			return false;
		}else {
			if(isNaN(parseLong(value))) {
				alert(name + "必须是长整数");
				return false;
			}
		}
	}
}
function checkFloat(name,value,nullable) {
	if(value == null){value="";}
	value = value.trim();
	if(nullable) {
		if(value == "") {
			return true;
		}else{
			if(isNaN(parseFloat(value))) {
				alert(name + "必须是浮点数");
				return false;
			}
		}
	}else {
		if(value == "") {
			alert(name + "不可为空");
			return false;
		}else {
			if(isNaN(parseFloat(value))) {
				alert(name + "必须是浮点数");
				return false;
			}
		}
	}
	return true;
}
function checkString(name,value,nullable) {
	if(value == null){value="";}
	value = value.trim();
	if(nullable) {
		if(value == "") {
			return true;
		}
	}else {
		if(value == "") {
			alert(name + "不可为空");
			return false;
		}
	}
	return true;
}
function openDialog(url,params,features,callback) {
	if(window.showModalDialog) {
		var result = window.showModalDialog(url,params,features);
		if(callback) {
			callback(result);
		}
	}else{
		var subwin = window.open(url,'open',features);
		subwin.dialogArguments = params;
		subwin.returnCallback = callback;
	}
}
function errDialog(errmsg) {
	openDialog("/pages/core/StackTrace.html",[errmsg],"dialogWidth:800px;dialogHeight:600px;status:no;help:no;center:yes");
}
function resourceDialog(resType,resurl,param,callback) {
	openDialog("/pages/core/Upload.html",[resType,resurl,param],"dialogWidth:800px;dialogHeight:600px;status:no;help:no;center:yes",callback);
}
function startMasker() {
	var masker = $("#framemasker",top.window.document);
	masker.show();
}
function stopMasker() {
	var masker = $("#framemasker",top.window.document);
	masker.hide();
}